// ================================================
// Remove href # on Url
// ================================================
/*  -------------------------*/
$(document).ready(function() {	
		$('a[href^=#]').click(function() {
			// เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�โ�ฌ๏ฟฝเน…เธ�เธ�
			var speed = 200;// เน�๏ฟฝ๏ฟฝเน�๏ฟฝเธ�เน�เธ�โ€�เน�๏ฟฝเธ�เน�โ€ขเธ�เน…เธ�โ€”เน�๏ฟฝโ€�เน…เธ�เธ�เน�๏ฟฝ๏ฟฝเน�๏ฟฝ๏ฟฝเน�๏ฟฝ๏ฟฝเน�๏ฟฝ๏ฟฝเน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�โ�ฌ๏ฟฝเน…เธ�เธ�เน�๏ฟฝ๏ฟฝเน�๏ฟฝโ€ฆเน�๏ฟฝ๏ฟฝเน�๏ฟฝเธ�เน�๏ฟฝ๏ฟฝ
			// เน�๏ฟฝเธ�เน�๏ฟฝเธ“เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน…โ�ฌเธ�เน…๏ฟฝโ€“เน…เธ�โ€”
			 var href= $(this).attr('href');
			// เน�เธ�เธ�เน…๏ฟฝโ€ขเน…โ€ฆ๏ฟฝเน�๏ฟฝโ€�เน…๏ฟฝโ€“เน…เธ�โ€”
			var target = $(href == '#' || href == '' ? 'html' : href);
			// เน�เธ�เธ�เน…๏ฟฝโ€ขเน…โ€ฆ๏ฟฝเน�๏ฟฝโ€�เน�โ€ขเธ�เน…โ�ฌเธ�เน�๏ฟฝเธ�เน…๏ฟฝโ€“เน…เธ�โ€”
			var position = target.offset().top;
			// เน�๏ฟฝเธ�เน�๏ฟฝย เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�เน�๏ฟฝเธ�
			$('body,html').animate({scrollTop:position}, speed, 'swing');
			return false;
		});
});

/*
|----------------------------------------------------------------------------------------------
| focus and animate
|----------------------------------------------------------------------------------------------
*/
$(document).ready(function() {		
			$('.animate').focus(function() {
	//			$(this).animate({ width: '99%' });
				$(this).animate({ width: '+=10%' });
				$(this).css({'border-color' : 'red'});
		});
		// Return Click
		
			$('.animate').blur(function() {
				$(this).css({
					width: "",
					fontSize: ""
				});
		});
});
/*
|----------------------------------------------------------------------------------------------
| Jquery Custom Pattern
|----------------------------------------------------------------------------------------------
*/
$(document).ready(function() {			   
		 $('.masked').mask("99/99/9999",{placeholder:" "});
//		 $('.date').mask("99/99/9999");
		 $('#tel_number,.tel').mask("9999-9999-9999");
		 $('#tin').mask("99-9999999");
});
/*
|----------------------------------------------------------------------------------------------
| Jquery Datepick
|----------------------------------------------------------------------------------------------
*/
$(document).ready(function() {			
//			$('.date').datepick({dateFormat: 'yyyy-mm-dd',minDate: 0});
});
$(function() {
//    $(".date").datepicker({ dateFormat: "yy-mm-dd",minDate: 0  });
    
    $('.date').datepicker({
    	dateFormat: "yy-mm-dd",minDate: 0,
        //comment the beforeShow handler if you want to see the ugly overlay
        beforeShow: function() {
            setTimeout(function(){
                $('#ui-datepicker-div').css('z-index', 99999999999999);
            }, 0);
        }
    });
});
/*
|----------------------------------------------------------------------------------------------
| Get Time
|----------------------------------------------------------------------------------------------
*/
$(document).ready(function() {			
			var dNow = new Date();
			var utc = new Date(dNow.getTime() + dNow.getTimezoneOffset() * 60000)
		//  Full formate
		//	var utcdate= (utc.getMonth()+1) + '/' + utc.getDate() + '/' + utc.getFullYear() + ' ' + utc.getHours() + ':' + utc.getMinutes();
			var utcdate= utc.getFullYear();
			$('#copyright').text(utcdate)
});
// ================================================
// Activate Pager For Testimonials
// ================================================
$(document).ready(function() {
    var current = $('.panel-container a > li');
    $('.panel-container a > li').click(function() {
        current.removeClass("active");
        current = $(this);
        current.addClass("active");
    });
});
// ================================================
// Activate slideshow for services
// ================================================
$(document).ready(function() {
    var current = $('.service-item');
    $(".service-item").click(function() {
        current.removeClass("active");
        current = $(this);
        current.addClass("active");
    });
});

// ================================================
// activate close button for widgets
// ================================================
$(document).ready(function() {
    $(".hideWidget").click(function() {
        
        $(this).parent().parent().fadeOut();
    return false;
    });
 // ================================================
 // plus and minus sign for accordion widget
 // ================================================
 $("ul#AccordionCaret > li > a").click(function() {
     $(this).toggleClass("Minus");
 });
 
});


$(document).ready(function() {
 // ================================================
 // jQuery scroll to up
 // ================================================
 $('#scrollTop').on("click", function() {
     $('html,body').animate({
         scrollTop: 0
     }, 'slow', function() {});
 });
});

// ================================================
// retina display
// ================================================
$(document).ready(function() {
    $('img').retina();
});

// ================================================
// JQUERY nivo slider
// ================================================
$(window).load(function() {
    
});
// ================================================
// Drop down Province and District end user
// ============================================== ==
$(document).ready(function() {

	    /*เน€เธ�๏ฟฝเน�เธ�เธ�เน€เธ�๏ฟฝ*******************************************************************************************เน€เธ�๏ฟฝเน�เธ�เธ�เน€เธ�๏ฟฝ*/
	    	
			var url="http://localhost/CI-svn";
	    	 
	    	 $("#pro_id_user").change(function(){
			        var selectValues = $("#pro_id_user").val();
			        if (selectValues == 0){
			            var msg = "province / Region :<br><select name=\"dis_id\" disabled><option value=\"Pilih province / Kabupaten\">Pilih country Dahulu</option></select>";
			            $('.dis').html(msg);
			        }else{
			            var pro_id = {pro_id:$("#pro_id_user").val()};
			            $('#dis_id').attr("disabled",true);
			            $.ajax({
			                    type: "POST",
			                    url : url+"/end_user/selectdistrict/"+selectValues,
			                    success: function(msg){
			                        $('.dis').html(msg);
			                    }
			            });
			        }
		    	 });
 
});
//================================================
//Drop down Province and District Company
//================================================
  $(document).ready(function () {
	  var url="http://localhost/CI-svn";
    /*เน�๏ฟฝเธ�*******************************************************************************************เน�๏ฟฝเธ�*/
	 $("#pro_id").change(function(){
   var selectValues = $("#pro_id").val();
   if (selectValues == 0){
       var msg = "province / Region :<br><select name=\"dis_id\" disabled><option value=\"Pilih province / Kabupaten\">Pilih country Dahulu</option></select>";
       $('.dis').html(msg);
   }else{
       var pro_id = {pro_id:$("#pro_id").val()};
       $('#dis_id').attr("disabled",true);
       $.ajax({
               type: "POST",
               url : url+"/company/selectdistrict/"+selectValues,
               success: function(msg){
                   $('.dis').html(msg);
               }
       });
   }
});

	 $( "#BTTnewrow" ).click(function() {

		var num_row = $("#HIDnum_row").val();

		num_row = parseFloat(num_row) + parseFloat(1);
		$("#HIDnum_row").val(num_row);

        $.ajax({
                type: "POST",
                url : url+"/company/selectSubprovince",
                success: function(msg){
                    $('.province'+num_row).html(msg);
                }

        });

		$("<div class='row'><div class='col-sm-12'><span class='pro'><label>Province </label>"+num_row+" : <select class='province"+num_row+"' name='subprovince[]'></select></span><span class='dis'><label>District </label> "+num_row+" : <select name='subdistrict[]' id='district"+num_row+"'><option value='0'>--- SELECT DISTRICT ---</option></select></span></div></div><div class='row'><div class='col-sm-12'><label>Area Detail </label>"+num_row+" :<textarea id='area_detail"+num_row+"' rows='10' placeholder='Area Detail' class='form-control contact-textarea' name='area_detail[]'></textarea></div></div>").insertBefore("#addNewRow");


   });
	 
//================================================
// Check Numeric
//================================================
	 $('.numeric').bind('keypress', function(e) {
	        return ( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)) ? false : true ;
	    });
//================================================
// disable button on submit when submit alr
//================================================	    
	 $('form').submit(function() {
	          $(":submit").attr("disabled", "disabled");
	 });
});
  
  $(document).keydown(function(e) {
	    var nodeName = e.target.nodeName.toLowerCase();

	    if (e.which === 8) {
	        if ((nodeName === 'input' && e.target.type === 'text') ||
	            nodeName === 'textarea') {
	            // do nothing
	        } else {
	            e.preventDefault();
	        }
	    }
	});
  


